/*
在ES5中，在函数体内，可以使用argument对象来迭代函数的参数。
在ES6中，可以使用rest parameter语法将不确定数量的参数定义为数组。
*/

//es5
function workoutEs5(exercises) {
    console.log(arguments);
    var todos = Array.prototype.slice.call(arguments, workoutEs5.length);
    console.log('Start from ' + exercises);
    console.log(todos.length + ' more to do');
}

workoutEs5('Treadmill', 'Pushup', 'Spinning');
//[Arguments] { '0': 'Treadmill', '1': 'Pushup', '2': 'Spinning' }
//Start from Treadmill
//2 more to do

console.log('------------');

//es6
function workoutEs6(exercises, ...todos) {
    console.log(todos);   //[ 'Pushup', 'Spinning' ]
    console.log('Start from ' + exercises);
    console.log(todos.length + ' more to do');
    console.log('Args length: ' + workoutEs6.length);  
}
workoutEs6('Treadmill', 'Pushup', 'Spinning');